//
//  UIViewController+TabBarControllerInternal.m
//  quanminzhekou
//
//  Created by zxl on 15/1/7.
//  Copyright (c) 2015年 zhongqinglongtu. All rights reserved.
//

#import "UIViewController+TabBarControllerInternal.h"
#import <objc/runtime.h>

@implementation UIViewController (TabBarControllerInternal)

- (void)setTabBarController:(TabBarViewController *)tabBarController {
    objc_setAssociatedObject(self, @selector(tabBarController), tabBarController, OBJC_ASSOCIATION_RETAIN);
}

- (TabBarViewController*)tabBarController {
    TabBarViewController *tBController = objc_getAssociatedObject(self, @selector(tabBarController));
    
    if (!tBController) {
        tBController = (TabBarViewController*)[UIApplication sharedApplication].keyWindow.rootViewController;
    }
    
    return tBController;
}

@end
